﻿using System.Text;
using Microsoft.SqlServer.Dts.Pipeline.Wrapper;

namespace NazTek.Documenter.Ssis.Control.Tasks.PipeSubComponent
{
    internal sealed class DerivedColumn : Base
    {
        internal DerivedColumn(IDTSComponentMetaData100 subComponent)
            : base(subComponent, null)
        {
        }

        protected override Operation GetOperation(SsisPipe parent)
        {
            var statement = new StringBuilder();
            foreach (IDTSOutputColumn100 col in Metadata.OutputCollection[0].OutputColumnCollection)
                statement.AppendFormat("{0} [{1}] = {2}<br>", col.Name, col.DataType,
                    col.CustomPropertyCollection["FriendlyExpression"].Value);
            return new Operation
            {
                ConnectionName = "Not Applicable",
                Statement = statement.ToString()
            };
        }
    }
}